package com.bbm.communitysystem.core.redis;

import com.bbm.communitysystem.domain.Role;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class RoleRedis {

    private final String ROLE_KEY = "role:";

    private final RedisTemplate<String, Role> redisTemplate;

    public RoleRedis(@Qualifier("role") RedisTemplate<String, Role> redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    public void setRole(String key, Role role) {
        redisTemplate.opsForValue().set(ROLE_KEY + key, role);
    }

    public Role getRole(String key) {
        return redisTemplate.opsForValue().get(ROLE_KEY + key);
    }

}
